package dao

import (
	"fmt"

	"gitee.com/liu_deping/gin-vue/db"
	"gitee.com/liu_deping/gin-vue/model"
)

func AddPost(post *model.Post) (*model.Post, error) {
	mydb := db.DB.AutoMigrate(&model.Post{})
	result := mydb.Create(post)
	err := result.Error
	if err != nil {
		fmt.Println(err)
		return nil, err
	}
	return post, nil
}
